package erfgame.core.graphics.renderer.render;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;

import erfgame.core.PointAndAngle;

public class ImageRender implements Render {

    private Image image;
    private Map<String, PointAndAngle> points;
    
    public ImageRender( Image image ) {
        this( image, new HashMap<String, PointAndAngle>() );
    }
    
    public ImageRender( Image image, Map<String, PointAndAngle> points ) {
        this.image = image;
        this.points = points;
    }
    
    public PointAndAngle getPoint(String id) {
        return points.get(id);
    }

    public Dimension getSize() {
        return new Dimension( image.getWidth(null), image.getHeight(null) );
    }

    public void render(Graphics g, int x, int y) {
        g.drawImage(image, x, y, null);
    }

	public boolean contains(int lx, int ly) {
		// assumes it's already in the bounds
		BufferedImage i = (BufferedImage)image;
		int argb = i.getRGB(lx, ly);
		return( (0xFF000000 & argb) != 0 );
	}
    
}
